package com.ruoyi.web.controller.biz;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.biz.BmClubMoney;
import com.ruoyi.system.service.biz.IBmClubMoneyService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 俱乐部基金Controller
 * 
 * @author xiangzhipeng
 * @date 2022-11-29
 */
@Controller
@RequestMapping("/biz/clubMoney")
public class BmClubMoneyController extends BaseController
{
    private String prefix = "biz/clubMoney";

    @Autowired
    private IBmClubMoneyService bmClubMoneyService;

    @RequiresPermissions("biz:clubMoney:view")
    @GetMapping()
    public String clubMoney()
    {
        return prefix + "/clubMoney";
    }

    /**
     * 查询俱乐部基金列表
     */
    @RequiresPermissions("biz:clubMoney:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BmClubMoney bmClubMoney)
    {
        startPage();
        List<BmClubMoney> list = bmClubMoneyService.selectBmClubMoneyList(bmClubMoney);
        return getDataTable(list);
    }

    /**
     * 导出俱乐部基金列表
     */
    @RequiresPermissions("biz:clubMoney:export")
    @Log(title = "俱乐部基金", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BmClubMoney bmClubMoney)
    {
        List<BmClubMoney> list = bmClubMoneyService.selectBmClubMoneyList(bmClubMoney);
        ExcelUtil<BmClubMoney> util = new ExcelUtil<BmClubMoney>(BmClubMoney.class);
        return util.exportExcel(list, "俱乐部基金数据");
    }

    /**
     * 新增俱乐部基金
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存俱乐部基金
     */
    @RequiresPermissions("biz:clubMoney:add")
    @Log(title = "俱乐部基金", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BmClubMoney bmClubMoney)
    {
        return toAjax(bmClubMoneyService.insertBmClubMoney(bmClubMoney));
    }

    /**
     * 修改俱乐部基金
     */
    @RequiresPermissions("biz:clubMoney:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        BmClubMoney bmClubMoney = bmClubMoneyService.selectBmClubMoneyById(id);
        mmap.put("bmClubMoney", bmClubMoney);
        return prefix + "/edit";
    }

    /**
     * 修改保存俱乐部基金
     */
    @RequiresPermissions("biz:clubMoney:edit")
    @Log(title = "俱乐部基金", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BmClubMoney bmClubMoney)
    {
        return toAjax(bmClubMoneyService.updateBmClubMoney(bmClubMoney));
    }

    /**
     * 删除俱乐部基金
     */
    @RequiresPermissions("biz:clubMoney:remove")
    @Log(title = "俱乐部基金", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bmClubMoneyService.deleteBmClubMoneyByIds(ids));
    }
}
